package com.gs.sqlite;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

@SpringBootApplication
public class SqliteApplication {


    public static void main(String[] args) {
        ApplicationContext applicationContext = SpringApplication.run(SqliteApplication.class, args);

        database db = (database) applicationContext.getBean(database.class);
        try {
            Connection conn = db.getConnection();
            String sql = "select * from hello";
            PreparedStatement ps = conn.prepareStatement(sql);
            ResultSet rs = ps.executeQuery();
            while (rs.next()){
                System.out.println(rs.getString("title"));
            }
            db.releaseResource();
        }catch (Exception e){
            e.printStackTrace();
        }
    }

}
